<script> 
	function deleteDocument() { 
   		if (confirm("Do you wish to delete \"" + $(this).attr("fc_doc") + "\"?" + "\nClick 'OK' to delete.")) { 
 			$.get("/files/delete?d=" + $(this).attr("fc_d") + "&c=" + $(this).attr("fc_c"), '', 
  				function (p) { 
 					if ("OK" != p.substring(0,2)) { 
						alert("Sorry, could not delete this file."); 
					} else { 
 						//window.location.reload(true); 
  						$.get( "<?php echo url_for('library/profileList').'?id='.$this_user_id ?>", {}, 
 							function(data) { 
								$('.profile-nav').next().replaceWith(data); 
							} 
						); 
					} 
			}, 'text'); 
		} 
	} 
	 
	function setupDeleteLinks() { 
	 	$('.delete-doc-lnk').click(deleteDocument); 
	} 
</script> 

<ul class="library-detail">

<?php foreach($files as $file):?>
	<li>

		<h4><a href="<?php echo $file->getAnnotateFileDownloadURL()?>"><?php echo $file->getName()?></a></h4>
		<p class="meta"><?php echo $file->getDownloadCount()?> Download(s) &nbsp;|&nbsp; <!--  PDF &nbsp;|&nbsp;--> [<?php echo $file->getSize()/1000?> MB] &nbsp;|&nbsp; <a target="blank" href="<?php echo $file->getAnnotateFileViewURL()?>">annotate</a>
		<?php if($file->getOwnerId() == $this_user_id) : ?> 
			&nbsp;|&nbsp;	
			<?php  
 				$desc = $file->getDescription(); 
				$disp_name = ($desc == "" ? $file->getName() : $desc);  
			?> 
			<a class="delete-doc-lnk" fc_c = "<?php echo $file->getCode(); ?> " fc_d = "<?php echo $file->getAnnotateDate(); ?>" fc_doc = "<?php echo $disp_name; ?>" href="javascript:void(0)">delete</a> 
 		<?php endif; ?> 
		</p>

		<p class="tags">
		<?php $tags = explode(',', $file->getTags());?>
		<?php foreach($tags as $index=>$tag):?>
			<a href="#"><?php echo $tag?></a>
		<?php endforeach?>
		
		</p>
						
		<p><?php echo $file->getDescription()?></p>
		
		
		<!--
		<p class="related"><strong>Related Content:</strong> <a href="#">The Tragedy of MacBeth</a>, <a href="#">English 10a</a></p>
		-->
	</li>
	<?php endforeach?>
</ul>

<script> 
 	setupDeleteLinks();
</script> 
